/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.upn.sigemfi.gar.be;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.DiscriminatorValue;

/**
 *
 * @author Programador
 */
@Entity
@Table(name = "GAR_GARANTIA")
@NamedQueries({
    @NamedQuery(name = "Garantia.findAll", query = "SELECT g FROM Garantia g"),
    @NamedQuery(name = "Garantia.findByIdGarantia", query = "SELECT g FROM Garantia g WHERE g.idGarantia = :idGarantia"),
    @NamedQuery(name = "Garantia.findByCobertura", query = "SELECT g FROM Garantia g WHERE g.cobertura = :cobertura"),
    @NamedQuery(name = "Garantia.findByTipogarantia", query = "SELECT g FROM Garantia g WHERE g.tipogarantia = :tipogarantia"),
    @NamedQuery(name = "Garantia.findByDocumentos", query = "SELECT g FROM Garantia g WHERE g.documentos = :documentos"),
    @NamedQuery(name = "Garantia.findByObservaciones", query = "SELECT g FROM Garantia g WHERE g.observaciones = :observaciones")
})
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "XTIPO", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue(value = "GAR")
public abstract class Garantia implements Serializable { //para la herencia
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID_GARANTIA", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    protected Long idGarantia; //protected para q puedan heredar
    @Column(name = "COBERTURA", length = 50)
    private String cobertura;
    @Basic(optional = false)
    @Column(name = "TIPOGARANTIA", nullable = false)
    private int tipogarantia;
    @Column(name = "DOCUMENTOS", length = 200)
    private String documentos;
    @Column(name = "OBSERVACIONES", length = 500)
    private String observaciones;
//    @OneToOne(cascade = CascadeType.ALL, mappedBy = "garantia", fetch = FetchType.LAZY)
//    private GarantiaLiquida garantiaLiquida;
//    @OneToOne(cascade = CascadeType.ALL, mappedBy = "garantia", fetch = FetchType.LAZY)
//    private GarantiaPignoraticia garantiaPignoraticia;
////    @OneToOne(cascade = CascadeType.ALL, mappedBy = "garantia", fetch = FetchType.LAZY)
////    private GarantiaPrendaria garantiaPrendaria;
//    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fidGarGarantia", fetch = FetchType.LAZY)
//    private List<EstadoGarantia> estadoGarantiaCollection;
////    @OneToOne(cascade = CascadeType.ALL, mappedBy = "garantia", fetch = FetchType.LAZY)
////    private Aval aval;
//    @OneToOne(cascade = CascadeType.ALL, mappedBy = "garantia", fetch = FetchType.LAZY)
//    private GarantiaHipotecaria garantiaHipotecaria;
//    @OneToOne(cascade = CascadeType.ALL, mappedBy = "garantia", fetch = FetchType.LAZY)
//    private GarantiaWarrant garantiaWarrant;

    public Garantia() {
    }

    public Garantia(Long idGarantia) {
        this.idGarantia = idGarantia;
    }

    public Garantia(Long idGarantia, int tipogarantia) {
        this.idGarantia = idGarantia;
        this.tipogarantia = tipogarantia;
    }

    public Long getIdGarantia() {
        return idGarantia;
    }

    public void setIdGarantia(Long idGarantia) {
        this.idGarantia = idGarantia;
    }

    public String getCobertura() {
        return cobertura;
    }

    public void setCobertura(String cobertura) {
        this.cobertura = cobertura;
    }

    public int getTipogarantia() {
        return tipogarantia;
    }

    public void setTipogarantia(int tipogarantia) {
        this.tipogarantia = tipogarantia;
    }

    public String getDocumentos() {
        return documentos;
    }

    public void setDocumentos(String documentos) {
        this.documentos = documentos;
    }

    public String getObservaciones() {
        return observaciones;
    }

    public void setObservaciones(String observaciones) {
        this.observaciones = observaciones;
    }

//    public GarantiaLiquida getGarantiaLiquida() {
//        return garantiaLiquida;
//    }
//
//    public void setGarantiaLiquida(GarantiaLiquida garantiaLiquida) {
//        this.garantiaLiquida = garantiaLiquida;
//    }
//
//    public GarantiaPignoraticia getGarantiaPignoraticia() {
//        return garantiaPignoraticia;
//    }
//
//    public void setGarantiaPignoraticia(GarantiaPignoraticia garantiaPignoraticia) {
//        this.garantiaPignoraticia = garantiaPignoraticia;
//    }

//    public GarantiaPrendaria getGarantiaPrendaria() {
//        return garantiaPrendaria;
//    }
//
//    public void setGarantiaPrendaria(GarantiaPrendaria garantiaPrendaria) {
//        this.garantiaPrendaria = garantiaPrendaria;
//    }

//    public List<EstadoGarantia> getEstadoGarantiaCollection() {
//        return estadoGarantiaCollection;
//    }
//
//    public void setEstadoGarantiaCollection(List<EstadoGarantia> estadoGarantiaCollection) {
//        this.estadoGarantiaCollection = estadoGarantiaCollection;
//    }

//    public Aval getAval() {
//        return aval;
//    }
//
//    public void setAval(Aval aval) {
//        this.aval = aval;
//    }

//    public GarantiaHipotecaria getGarantiaHipotecaria() {
//        return garantiaHipotecaria;
//    }
//
//    public void setGarantiaHipotecaria(GarantiaHipotecaria garantiaHipotecaria) {
//        this.garantiaHipotecaria = garantiaHipotecaria;
//    }
//
//    public GarantiaWarrant getGarantiaWarrant() {
//        return garantiaWarrant;
//    }
//
//    public void setGarantiaWarrant(GarantiaWarrant garantiaWarrant) {
//        this.garantiaWarrant = garantiaWarrant;
//    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idGarantia != null ? idGarantia.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Garantia)) {
            return false;
        }
        Garantia other = (Garantia) object;
        if ((this.idGarantia == null && other.idGarantia != null) || (this.idGarantia != null && !this.idGarantia.equals(other.idGarantia))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.upn.sigemfi.gar.be.Garantia[idGarantia=" + idGarantia + "]";
    }

}
